<!DOCTYPE html>
<html>
<head>
	<meta charset="UTF-8">
	<meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
	<title></title>
	<meta name="format-detection" content="telephone=no"/>
	<link rel="stylesheet" type="text/css" href="../css/api.css" />
    <link rel="stylesheet" type="text/css" href="../css/common.css" />
	<link rel="stylesheet" type="text/css" href="../css/list.css" />
</head>
<body>
	<div class="h10"></div>	  
	<div id="main_content">
	 
	
	</div>
  	<div id="divNoDataTip">
		<div id="textTip" style="margin-top:10px;margin-bottom:10px;width:100%;text-align: center;" 
			class="button red" tapmode="">正在加载..</div>
	</div> 
	<div class="h10"></div>
	<input id="pageIndex" type="hidden" value="0"/>
	<input id="pageSize" type="hidden" value="20"/>
</body>
<script type="text/javascript" src="../script/api.js"></script>  
<script type="text/javascript" src="../script/alpenlicebe.js"></script>   
<script type="text/javascript" src="../script/zepto.min.js"></script>
<script type="text/javascript" src="../script/hashes.min.js"></script> 
<script>
	apiready = function(){ 
 		/*下拉刷新*/
    	api.setRefreshHeaderInfo({
            visible: true,
            loadingImg: 'widget://image/refresh.png',
            bgColor: '#fff',
            textColor: '#000',
            textDown: '下拉刷新...',
            textUp: '松开刷新...',
            showTime: true
        }, function (ret, err) { 
        	$("#pageIndex").val(0); 
        	$("#main_content").html(""); 
        	$("#textTip").html("正在加载..");
            goto_loadDataFun();
            api.refreshHeaderLoadDone();
        }); 
        
       	/*滑动到底部加载数据*/
   		api.addEventListener({name: 'scrolltobottom'}, function (ret, err) {
            goto_loadDataFun();
        });  
        /*注册监听事件-用户登录*/
		api.addEventListener({
		    name: 'Alpe_Event_UserLogin'
		}, function(ret){
		    if(ret){ 
		   		$("#pageIndex").val(0); 
	        	$("#main_content").html(""); 
	        	$("#textTip").html("正在加载..");
	            goto_loadDataFun();
		    }
		}); 
        if(''==Alpe_getLocalStorge('sys_userID')){ 
  			var delay = 0; 
		 	if("ios" != api.systemType){
		    	delay = 300;
		  	} 
			api.openWin({
	            name: 'login',
	            url: './login.html',
	            bounces: false,
	            reload: true,
	            rect: {
	                x: 0,
	                y: 0,
	                w: 'auto',
	                h: 'auto'
	            },
	            delay: delay
	   		}); 
       		
       	}else{
        	/*初始化加载数据*/
       		goto_loadDataFun();   
       	} 
	}  
	
    function goto_loadDataFun() {  
        goto_loadNewsListFun(); 
        api.parseTapmode();  
    } 
	function goto_loadNewsListFun(){ 
		var userID=Alpe_getLocalStorge('access_token');  
    	/*if(''==userID){
    		api.alert({title:'系统提示',msg:'您未登录'});
			return;
    	}*/
		var pageIndex=parseInt($("#pageIndex").val())+1;
		var pageSize=$("#pageSize").val();
		$("#pageIndex").val(pageIndex);
		
		api.showProgress({
		    style: 'default',
		    animationType: 'fade',
		    title: '',
		    text: '',
		    modal: false
		});
		
		var MD5 = new Hashes.MD5;   
       	var access_token = Alpe_getLocalStorge("access_token");                     
       	var admin_id = Alpe_getLocalStorge("admin_id"); 
       	var sign = MD5.hex(access_token+admin_id+pageIndex+'datas/getDaily1.0syjqingbao');
            
       	var url = Alpe_ApiUrl+'r=datas/getDaily&access_token='+access_token+'&admin_id='+admin_id
       		+'&page='+pageIndex+'&v=1.0&sign='+sign;
       	api.ajax({
	         url: url,
	         method: 'get',
	         cache: false,
	         timeout: 30,			
	         dataType: 'json'
       	}, function(ret, err){
			if (ret) {	 
				if(ret.success == '100'){  
					if(ret.dailymsg.length<3){
						api.removeEventListener({name:'scrolltobottom'}); 
                 		$("#textTip").html("暂无更多数据");
					}  	
					var cssStr="border-bottom: 1px solid #D4D3D3;padding-bottom:20px;";
	                $.each(ret.dailymsg, function (index, v) {
	                      var html = '<div class="home-tuan-list" id="list_content"><div class="item hightitem" style="text-align:center; padding-top:10px; font-size: 1.4em; font-weight: bold";>'+v.days+'</div>';	                         	                                 
                          $.each(v.list, function (key, value){
                          	if(key==v.list.length-1){
                          		cssStr="padding-bottom:20px;";
                          	}else{
                          		cssStr="border-bottom: 1px solid #D4D3D3;padding-bottom:20px;";
                          	}
                     		html += '<div class="item Fix hightitem"><div class="cnt"><div class="wrap"><div class="wrap2"><div class="content"><div class="shopname hot-title" style="margin-left: auto;margin-right: auto;text-align:center;display:block;width:100%">'+value.title
                     				+'</div><div class="title hot-subtitle">'+value.abstract_content
                     				+'</div><div class="img"></div><div class="info" style="'+cssStr+'" onclick="goto_openPhoneBrowerFun(\''+value.url+'\')" tapmode="presshover">'+value.url
                     				+'</div></div></div></div></div></div>';	
	                      });
                          html +='</div><div class="h20"></div>';
                          $("#main_content").append(html);			     
	                 }); 
	                 api.hideProgress(); 
				}else if("002"==ret.success||"003"==ret.success){ 
					api.hideProgress();
					goto_openWin_loginWin(ret.message);
				}else{	
					api.removeEventListener({name:'scrolltobottom'}); 
               		$("#textTip").html(ret.message);			 
					api.toast({
		         		msg: ret.message,
                 		duration:2000,
                    	location: 'middle'
               		}); 
               		api.hideProgress();        
		  		} 
			}else{
				api.alert({title:'系统提示',msg:'网络链接超时，请返回重试'}); 
				api.hideProgress();
			} 
   		});
	}
 
	function goto_openPhoneBrowerFun(url){       		    
		if('ios'==api.systemType){
      		api.openApp({
				iosUrl: url
			},function(ret,err){ 
					     
			});
   		}	
        if('android'==api.systemType){
        	api.openApp({
			    androidPkg: 'android.intent.action.VIEW',
			    
			    uri: url
			},function(ret,err){ 
			});
        }	 	 
	} 
</script>
</html>